<template>
  <div>
   <div v-for="(item,index) in arr " :key="index" style="display: inline-block">
    <!-- 使用v-bind指令让input表单的value值为arr数组每一项 -->
     <input type="checkbox" v-model="newArr" :value="item">
     <span>{{item}}</span>
    </div>
    <p>你选中的元素的和为:{{thisAll}}</p>
  </div>
</template>

<script>
export default {
   data(){
     return {
       arr:[9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
       newArr:[],
     }
   },
   computed:{
     thisAll(){
      return this.newArr.reduce((sum ,prev )=>sum + prev,0)
     }
   }
}
</script>

<style>

</style>